﻿using UnityEngine;
using System.Collections;

public class ButtonMoveAnim : MonoBehaviour
{

    private float range = 0;
    private Vector3 initPosition;
    private float deltaY;
    private bool isIncrease = true;
    private float deltaMove = 0.02f;
    // Use this for initialization
    void Start()
    {
        initPosition = gameObject.transform.position;
    }

    // Update is called once per frame
    void Update()
    {
        if (isIncrease)
        {
            if (range < 180)
            {
                range += deltaMove;
            }
            if (range == 180)
            {
                isIncrease = false;
            }
        }
        else
        {
            if (range > 0)
            {
                range -= deltaMove;
            }
            if (range == 0)
            {
                isIncrease = true;
            }
        }
        deltaY = Mathf.Cos(range);
        gameObject.transform.position = initPosition + new Vector3(0, deltaY, 0);
    }
}
